package com.logisticsinquiry.android.ui.trace

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.logisticsinquiry.android.logic.Repository
import com.logisticsinquiry.android.logic.model.ExpressQueryResponse

class TraceViewModel:ViewModel() {
    private val logisticCodeLiveData = MutableLiveData<String>()
    val traceList = ArrayList<ExpressQueryResponse.Trace>()
    val expressQueryLiveData = Transformations.switchMap(logisticCodeLiveData){
            logisticCode -> Repository.expressQuery(logisticCode)
    }

    fun expressQuery(logisticCode: String){
        logisticCodeLiveData.value = logisticCode
    }

}